<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Driver extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('driver',['engine'=>'InnoDB','comment'=>'司机表']);
        $table->addColumn('company_id', 'integer',['limit'=>11,'default'=>0,'comment'=>'所属公司id','after'=>'id'])
            ->addColumn('no', 'string',['limit'=>50,'default'=>'','comment'=>'司机编号','after'=>'company_id'])
            ->addColumn('name', 'string',['limit'=>50,'default'=>'','comment'=>'司机姓名','after'=>'no'])
            ->addColumn('age', 'integer',['limit'=>11,'default'=>0,'comment'=>'年龄','after'=>'name'])
            ->addColumn('sex', 'integer',['limit'=>11,'default'=>0,'comment'=>'性别','after'=>'age'])
            ->addColumn('id_card', 'string',['limit'=>50,'default'=>'','comment'=>'身份证号','after'=>'sex'])
            ->addColumn('phone', 'string',['limit'=>50,'default'=>'','comment'=>'手机号','after'=>'id_card'])
            ->addColumn('status', 'integer', ['default' => 1, 'limit' => 1, 'comment' => '状态：1启用 2禁用'])
            ->addColumn('job_status', 'integer', ['default' => 1, 'limit' => 1, 'comment' => '在职状态：1在职 2离职'])
            ->addColumn('address', 'string',['limit'=>255,'default'=>'','comment'=>'地址','after'=>'status'])
            ->addColumn('license_type', 'string',['limit'=>50,'default'=>'','comment'=>'驾照类型','after'=>'address'])
            ->addColumn('remark', 'string',['limit'=>255,'default'=>'','comment'=>'备注','after'=>'license_type'])
            ->addColumn('sort', 'integer',['limit'=>11,'default'=>0,'comment'=>'排序','after'=>'remark'])
            ->addColumn('create_time', 'integer',['limit'=>11,'default'=>null,'comment'=>'创建时间','after'=>'sort'])
            ->addColumn('update_time', 'integer',['limit'=>11,'default'=>null,'comment'=>'更新时间','after'=>'create_time'])
            ->addColumn('delete_time', 'integer',['limit'=>11,'default'=>null,'comment'=>'删除时间','after'=>'update_time'])
            ->addIndex('company_id')
            ->addIndex('no')
            ->addIndex('name')
            ->addIndex('phone')
            ->create();
    }
}
